/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gob.inamhi.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dhinojosa
 */
@Entity
@Table(name = "esge", schema="administrative")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Esge.findAll", query = "SELECT e FROM Esge e"),
    @NamedQuery(name = "Esge.findByEsgeId", query = "SELECT e FROM Esge e WHERE e.esgeId = :esgeId"),
    @NamedQuery(name = "Esge.findByEsgenomb", query = "SELECT e FROM Esge e WHERE e.esgenomb = :esgenomb")})
public class Esge implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "esge__id")
    private Integer esgeId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "esgenomb")
    private String esgenomb;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "esgeId")
    private Collection<Cain> cainCollection;

    public Esge() {
    }

    public Esge(Integer esgeId) {
        this.esgeId = esgeId;
    }

    public Esge(Integer esgeId, String esgenomb) {
        this.esgeId = esgeId;
        this.esgenomb = esgenomb;
    }

    public Integer getEsgeId() {
        return esgeId;
    }

    public void setEsgeId(Integer esgeId) {
        this.esgeId = esgeId;
    }

    public String getEsgenomb() {
        return esgenomb;
    }

    public void setEsgenomb(String esgenomb) {
        this.esgenomb = esgenomb;
    }

    @XmlTransient
    public Collection<Cain> getCainCollection() {
        return cainCollection;
    }

    public void setCainCollection(Collection<Cain> cainCollection) {
        this.cainCollection = cainCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (esgeId != null ? esgeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Esge)) {
            return false;
        }
        Esge other = (Esge) object;
        if ((this.esgeId == null && other.esgeId != null) || (this.esgeId != null && !this.esgeId.equals(other.esgeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gob.inamhi.entidades.Esge[ esgeId=" + esgeId + " ]";
    }
    
}
